import java.util.ArrayList;
import java.util.List;

public class CinemaSystem {
    private List<Hall> halls;
    private List<Movie> movies;
    private List<Session> sessions;
    private List<User> users;
    private List<Ticket> tickets;

    private FrontService frontService;
    private AdminService adminService;
    private SessionService sessionService;
    private MovieService movieService;

    public CinemaSystem() {
        this.halls = new ArrayList<>();
        this.movies = new ArrayList<>();
        this.sessions = new ArrayList<>();
        this.users = new ArrayList<>();
        this.tickets = new ArrayList<>();

        this.frontService = new FrontService(this);
        this.adminService = new AdminService(this);
        this.sessionService = new SessionService(this);
        this.movieService = new MovieService(this);
    }

    public List<Hall> getHalls() {
        return halls;
    }

    public List<Movie> getMovies() {
        return movies;
    }

    public List<Session> getSessions() {
        return sessions;
    }

    public List<User> getUsers() {
        return users;
    }

    public List<Ticket> getTickets() {
        return tickets;
    }

    public FrontService getFrontService() {
        return frontService;
    }

    public AdminService getAdminService() {
        return adminService;
    }

    public SessionService getSessionService() {
        return sessionService;
    }

    public MovieService getMovieService() {
        return movieService;
    }

    public void initUsers() {
        // 初始化管理员用户
        users.add(new User("U001", "admin", "ynuinfo#777", "管理员", "13800138000"));
    }

    /**
     * 初始化基础数据（放映厅,电影，放映场次）
     */
    public void initData() {
        // 初始化5个放映厅
        halls.add(new Hall("黄金厅", 8, 10));
        halls.add(new Hall("白银厅", 10, 12));
        halls.add(new Hall("翡翠厅", 7, 8));
        halls.add(new Hall("钻石厅", 7, 8));
        halls.add(new Hall("宝石厅", 8, 9));

        // 初始化五部电影
        movies.add(new Movie("M001", "肖申克的救赎", "弗兰克·德拉邦特", "蒂姆·罗宾斯", "希望让人自由。", 142, 9.7));
        movies.add(new Movie("M002", "霸王别姬", "陈凯歌", "张国荣", "一段传奇人生，半世浮沉。", 171, 9.6));
        movies.add(new Movie("M003", "阿甘正传", "罗伯特·泽米吉斯", "汤姆·汉克斯", "人生就像一盒巧克力。", 142, 9.5));
        movies.add(new Movie("M004", "泰坦尼克号", "詹姆斯·卡梅隆", "莱昂纳多·迪卡普里奥", "一段跨越阶级的爱情故事。", 195, 9.4));
        movies.add(new Movie("M005", "千与千寻", "宫崎骏", "柊瑠美", "少女千寻的奇幻冒险。", 125, 9.3));

        // 初始化放映场次
        sessions.add(new Session("S001", movies.get(0), halls.get(0), 50.0));
        sessions.add(new Session("S002", movies.get(1), halls.get(1), 60.0));
        sessions.add(new Session("S003", movies.get(2), halls.get(2), 55.0));
        sessions.add(new Session("S004", movies.get(3), halls.get(3), 70.0));
        sessions.add(new Session("S005", movies.get(4), halls.get(4), 45.0));
    }    
}
